class Hymn < ActiveRecord::Base
  belongs_to :album
  file_column :mp3_file, :extensions => { "audio/mpeg" => "mp3", "audio/x-wav" => "mid", "audio/x-wav" => "wav" }
  acts_as_taggable

  validates_uniqueness_of :title
  validates_presence_of :title, :album, :lyrics

  def related_templates
    Template.find_tagged_with(self.tag_list)
  end

  def related_images
    Image.find_tagged_with(self.tag_list)
  end

  # active_scaffold callbacks: authorized_for_crud
  def authorized_for_create?
    true
  end

  def authorized_for_read?
    true
  end

  def authorized_for_update?
    true
  end

  def authorized_for_destroy?
    true
  end

  # human names
  ModelName = "赞美诗"
  ColumnNames ={
    :title => "标题",
    :album => "专辑",
    :byline => "副标题",
    :lyrics => "歌词",
    :mp3_file => "音频文件",
    :tag_list => "标签",
    :related_images => "相关图片",
    :related_templates => "相关模版",
  }
end
